package com.fau.wmbj.server.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.vladmihalcea.hibernate.type.json.JsonStringType;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 订单成员
 *
 * @author jiawei
 * @version 1.0
 * @datetime 2024-03-06 16:24
 */
@Getter
@Setter
@Entity(name = "f_order_member")
@TypeDef(name = "json", typeClass = JsonStringType.class)
public class OrderMember extends BaseEntity<Long> implements Serializable {

    /**
     * 订单
     */
    @JsonIgnore
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "order_id")
    private Order order_;

    /**
     * 订单
     */
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "user_id")
    private User user;

    /**
     * 角色名称
     */
    @Column(name = "role_name")
    private String roleName;

    /**
     * 权限
     */
    @Lob
    @Column(name = "purview_")
    @Type(type = "json")
    private List<String> purview = new ArrayList<>();

    @Lob
    @Column(name = "config")
    @Type(type = "json")
    private Map<String, Object> config = new HashMap<>();

    @Transient
    private Long userId;
}
